<template>
    <div>

        <el-table
                v-loading="$store.state.load"
                :data="$store.state.admin.adminInfo"
                style="width: 100%">
            <el-table-column
                    label="管理员账号"
                    width="180">
                <template slot-scope="scope">
                    {{scope.row.adminName}}
                </template>
            </el-table-column>
            <el-table-column
                    label="管理员密码"
                    width="180">
                <template slot-scope="scope">
                    {{scope.row.passWord}}
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">

                    <el-button
                            size="mini"
                            type="danger"
                            @click="$store.dispatch('deleteAdminUser',scope.row._id)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>



        <pageInfo action-name="getAdminData" ></pageInfo>
        <div>
            <input type="text" v-model="adminForm.zhanghao"><br>
            <input type="message" v-model="adminForm.mima"><br>
            <input type="button" value="添加管理员" @click.prevent="tijiao">
        </div>
    </div>
</template>

<script>
    export default {
        name: "AdminList",
        data() {
            return {
                adminForm:{
                    zhanghao:"",
                    mima:""
                }
            }
        },
        methods:{
            tijiao(){
                this.$store.dispatch("addAdminForm",this.adminForm)
                    .then(data=>{
                        if(data.ok===1){
                            this.$store.dispatch("getAdminData")
                        }else{
                            this.$message.error(data.msg)
                        }

                    })
            }
        }

    }
</script>

<style scoped>

</style>